<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">

<title>电子文档系统</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<script type="text/javascript" src="view/jquery/jquery-1.9.1.js"></script>
	<script type="text/javascript" src="view/js/docMan.js"></script>
	<script type="text/javascript" src="view/bootstrap/js/bootstrap.js"></script>
<link rel="stylesheet" href="view/bootstrap/css/bootstrap.css">

<link rel="stylesheet" href="zcfg/css/menu_left.css" media="screen" />
<link rel="stylesheet" href="view/css/docMan.css">
<style type="text/css">

	#menu ul {
	padding-left: 15px;
	/* height: 300px; */
	height:auto;
	border: #E7E7E7 0px solid;
	border-top: none;
	overflow: auto;
	}
	#menu span{
		padding:4px 4px;
		/* min-height:25px; */
		font-size: 14px;
	}
	#menu span:HOVER {
		background-color: #277fc2;
		font-color: #fff;
		color: #fff;
	}
	.dbclick{
		background-color: #277fc2;
		font-color: #fff;
		color: #fff;
	}
</style>
</head>

<body style="background: #EDEFF0;">
	<div id="main-container" class="container"
		style="height: 100%;width:100%;background: #EDEFF0;padding-top:20px;">
		<div class="row bookSonsList" style="width:100%;margin-left:0">
			<table class="table table-striped table-bordered ">
				<thead>
					<tr>
						<th class="col-md-5">文件名</th>
						<th class="col-md-4">创建时间</th>
						<th class="col-md-3">操作</th>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="bookSonPage.result" id="bookSon" status="stu">
						<tr>
							<td class="bookSonName"><s:property value="#bookSon.subTitle" /></td>
							<td><s:date name="#bookSon.createTime" format="yyyy-MM-dd"/></td>
							<td><button style="padding:3px 9px;" value='<s:property value="#bookSon.id" />' class="btn btn-default btn-bookSonLook" >查看</button>
								<button style="padding:3px 9px;" value='<s:property value="#bookSon.id" />'   class="btn btn-primary btn-editBookSonModal">编辑</button>
								<button style="padding:3px 9px;" value='<s:property value="#bookSon.id" />' class="btn btn-danger btn-bookSonDelModal">删除</button>
								</td>
						</tr>
					</s:iterator>
				</tbody>
			</table>	
		</div>
		<!--分页按钮  -->
		<div class="row" style="margin-top: 10px;margin-bottom: 20px;margin-left: 20px;">
			<form id="bookSonFather" name="bookSonFather" action="bookSonFather.action"
				method="get">
				<input name="bookSonId" value='<s:property value="bookSonId" />' style="display: none;">
				<input name="bookSonPage.everyPage" value="10" style="display: none;"">
				<div class="row" style="margin-top: 20px;margin-bottom: 20px;">
  					<button class="btn btn-link prePage" <s:if test='bookSonPage.hasPrePage==false' >disabled="disabled"</s:if> >上一页</button>
  					<input type="number" id="pageIndex" value='<s:property value="bookSonPage.currentPage" />' style="width:80px;display: inline;" class="form-control">
  					<input type="number" id="currentPage" name="bookSonPage.currentPage" value='<s:property value="bookSonPage.currentPage"/>' style="display: none;">
  					<input id="totalPage" value='<s:property value="bookSonPage.totalPageCount" />' style="display: none;">
  					<button class="btn btn-link nextPage" type="button" <s:if test='bookSonPage.hasNextPage==false' >disabled="disabled"</s:if>>下一页</button>
  					共<span class="pageCount" ><s:property value="bookSonPage.totalPage"/> </span>页，<s:property value="bookSonPage.totalCount"/>条记录
  				</div>
					<%-- <s:if test="#session.admin==true">
						<button class="btn btn-primary" type="button" id="btn_addBookModal" style="margin-left:20px;">添加书本</button>
					</s:if> --%>
			</form>
		</div>
	</div>
	
	
	<div id="pfdModal" class="modal fade">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-body">
								<iframe id="pdfIframe" name="pdfIframe"  contextmenu="return false"
									scrolling="yes" src=""
									style="width:100%;height: 100%;@media print{ body{display:none} } ">
								</iframe>
							</div>
							<div class="">
								<div class="row">
									<div class="" style="margin-left:45%;">
										<!-- <button type="button" class="btn btn-primary"
											data-dismiss="modal">返回</button> -->
											<button type="button"  data-dismiss="modal" class="btn btn-primary"
											>返回</button>
										<!-- <button type="button" class="btn btn-danger print"
											>打印</button> -->
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
		<div id="delModal" class="modal fade">
					<div class="modal-dialog">
						<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
							<h4 class="modal-title" id="exampleModalLabel">删除确认</h4>
						</div>
							<div class="modal-body">
								<div class="row">
									<span>确认删除</span>
									<input id="delBookSonId" value="" style="display: none;">
								</div>
							</div>
							<div class="">
								<div class="row">
									<div class="" style="margin-left:45%;">
											<button type="button"  class="btn btn-primary btn-delBookSon"
											>删除</button>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				
	<!--编辑-->
	<div class="modal fade" id="bookSonEditModal" tabindex="-1" role="dialog"
		aria-labelledby="exampleModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="exampleModalLabel">标题编辑</h4>
				</div>
				<div class="modal-body">
					<form>
						
						<div class="form-group">
							<input style="display: none;" id="editBookSonId">
							<label for="dirRange" class="control-label">标题:</label> 
							<input type="text" class="form-control" id="bookSonSubTitle" placeholder="目录名字"  >
							</select>
						</div>
						
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" id="btn-editBookSon" class="btn btn-primary">保存</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				</div>
			</div>
		</div>
	</div>
</body>
</html>

<script type="text/javascript">
$(function(){
	$(".btn-bookSonLook").on("click",function(){
		var id = $(this).val();
		var url = "officeFilePreview.action?bookSonId="+id+"&isFather=false";
		/* $("#pdf").attr("src",url);
		$("#pdfModal").toggle(400); */
		var height = 800//$(window).height();
		var width = $(window).width();
		var pdf = $("#pfdModal");
		$("#pdfIframe").attr('src', url);
		$("#jnmlModal").modal('hide');
		pdf.find(".modal-body").css({
			height : height - 80
		});
		pdf.find(".modal-dialog").css({
			width : width,
			height : height,
			margin : 0
		});
		pdf.modal('show').css({
			width : width,
			height : height
		});
	});
	$(".btn-editBookSonModal").on("click",function(){
		var bookSonId=$(this).val();
		var name=$(this).parent().prev().prev().text();
		$("#bookSonSubTitle").val(name);
		$("#editBookSonId").val(bookSonId);
		$("#bookSonEditModal").modal('show');
	});
	$("#btn-editBookSon").on("click",function(){
		var bookSonTitle=$("#bookSonSubTitle").val();
		if(bookSonTitle.length==0){
			toast.error("名字不能为空", "温馨提示");
			return false;
		}
		var bookSonId=$("#editBookSonId").val();
		$.ajax({
			type:"post",
			url:"/DocMan/webService/show/DocBookSon/editBookSon",
			data:{bookSonId:bookSonId,
				bookSonName:bookSonTitle,
				orderId:0
			},
			success:function(){
				refresh();
			},
			error:function(){
			}
		})
	});
	$(".btn-bookSonDelModal").on("click",function(){
		var bookSonId=$(this).val();
		$("#delBookSonId").val(bookSonId);
		$("#delModal").modal('show');
	});
	$(".btn-delBookSon").on("click",function(){
		var bookSonId=$("#delBookSonId").val();
		$.ajax({
			type:"post",
			url:"/DocMan/webService/show/DocBookSon/delBookSon",
			data:{bookSonId:bookSonId},
			success:function(){
				refresh();
			},
			error:function(){
			}
		})
	});
	$(".prePage").on("click", function() {
		var pageCount = Number($("#currentPage").val()) - 1;
		$("#currentPage").val(pageCount);
		$("#bookSonFather").submit();
	});
	$(".nextPage").on("click", function() {
		var pageCount = Number($("#currentPage").val()) + 1;
		$("#currentPage").val(pageCount);
		console.info($("#currentPage").val());
		$("#bookSonFather").submit();
	});
})
</script>
